package com.sbpm.crmbpm.client.deprecforms;

import com.sencha.gxt.widget.core.client.box.MessageBox;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by TT on 26.10.2014.
 */
public class FormFactory
{

    private Map<String, ProcessForm> forms = new HashMap<>();

    public ProcessForm createForm( String formName, Long taskId, String user )
    {
        if( forms.get( formName ) == null )
        {
            switch( formName )
            {

                case "CreateRequest":
                {
                    forms.put( formName, new CreateInsuranceRequestForm() );
                    break;
                }
                case "VerifyRequest":
                {
                    forms.put( formName, new VerifyInsuranceRequestForm() );
                    break;
                }
                case "NotifyPersonalManager":
                {
                    forms.put( formName, new NotifyPersonalManagerForm() );
                    break;
                }
                case "ReviewScene":
                {
                    forms.put( formName, new ReviewSceneForm() );
                    break;
                }
                case "Expertise":
                {
                    forms.put( formName, new ExpertiseForm() );
                    break;
                }
                case "DamageAssessment":
                {
                    forms.put( formName, new DamageAssessmentForm() );
                    break;
                }
                case "RefusePayment":
                {
                    forms.put( formName, new RefusePaymentForm() );
                    break;
                }
                case "LegalApproval":
                {
                    forms.put( formName, new LegalApprovalForm() );
                    break;
                }
                case "ComplianceApproval":
                {
                    forms.put( formName, new ComplianceApprovalForm() );
                    break;
                }
                case "DirectorLevelApproval":
                {
                    forms.put( formName, new DirectorLevelApprovalForm() );
                    break;
                }
                case "InsuranceBenefit":
                {
                    forms.put( formName, new InsuranceBenefitForm() );
                    break;
                }
                default:
                {
                    MessageBox box = new MessageBox( "FormFactory cannot create a form. Form " + formName + " not found" );
                    box.show();
                    return null;
                }
            }

        }
        ProcessForm form = forms.get( formName );
        form.setTaskId( taskId );
        form.setUser( user );
        return form;
    }
}
